<template>
	<view>
		<z-paging ref="paging" v-model="dataList" @query="queryList">
			<view class="item" v-for="(item, index) in dataList" :key="index" @click="itemClick(item)">
				<image :src="item.imageUrl"></image>
				<view class="title">
					<view style="flex: 1;">{{item.title}}</view>
					<view class="time">{{item.createTime}}</view>
				</view>
				<text class="sub-title two-line" v-html="item.message"></text>
			</view>
		</z-paging>
	</view>
</template>

<script>
	import RouteUtil from '../../../common/RouteUtil';
	export default {
		data() {
			return {
				dataList: [],
			};
		},
		methods: {
			async queryList(pageNo, pageSize) {
				const params = {
					pageNo: pageNo,
				}
				let res = await this.$common.get("/api/banner/list", params);
				if (200 == res.code) {
					this.$refs.paging.complete(res.data);
				} else {
					this.$refs.paging.complete(false);
				}
			},
			itemClick(item) {
				RouteUtil.toNoticeDetail(item)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.item {
		display: flex;
		flex-direction: column;
		background-color: #fff;
		margin: 30rpx;
		border-radius: 15rpx;

		image {
			width: 100%;
			height: 300rpx;
			border-radius: 15rpx;
		}

		.title {
			display: flex;
			flex-direction: row;
			align-items: center;
			margin: 15rpx 15rpx 0;
			font-size: 36rpx;
			color: #222;
			font-weight: bold;

			.time {
				font-size: 20rpx;
				color: #888;
				font-weight: normal;
			}
		}

		.sub-title {
			margin: 15rpx;
			font-size: 24rpx;
			color: #555;
		}

		.two-line {
			display: -webkit-box;
			-webkit-line-clamp: 2;
			-webkit-box-orient: vertical;
			overflow: hidden;
		}
	}
</style>